package cian_f_rice.controller;

/**
 * @author Cian
 */

import javax.swing.JTextField;

import cian_f_rice.model.DecisionLinesEvent;
import cian_f_rice.view.DecisionLinesGUI;

public class ChoiceController {

	DecisionLinesEvent model;
	DecisionLinesGUI application;
	int position;
	
	public ChoiceController(DecisionLinesEvent model, DecisionLinesGUI application, int position)
	{
		this.model = model;
		this.application = application;
		this.position = position;
	}
	
	public void process()
	{
		JTextField choiceField = application.getChoice(position);
		
		if (!model.setChoice(position, choiceField.getText()))
			{
				application.setStatus("Duplicate choice name.");
				choiceField.setText(null);
			}			

	}
}
